import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '表名',
    align:"center",
    dataIndex: 'tableName'
   },
   {
    title: '表类型: 0单表、1主表、2附表',
    align:"center",
    dataIndex: 'tableType'
   },
   {
    title: '表版本',
    align:"center",
    dataIndex: 'tableVersion'
   },
   {
    title: '表说明',
    align:"center",
    dataIndex: 'tableTxt'
   },
   {
    title: '是否带checkbox',
    align:"center",
    dataIndex: 'isCheckbox'
   },
   {
    title: '同步数据库状态',
    align:"center",
    dataIndex: 'isDbSynch'
   },
   {
    title: '是否分页',
    align:"center",
    dataIndex: 'isPage'
   },
   {
    title: '是否是树',
    align:"center",
    dataIndex: 'isTree'
   },
   {
    title: '主键生成序列',
    align:"center",
    dataIndex: 'idSequence'
   },
   {
    title: '主键类型',
    align:"center",
    dataIndex: 'idType'
   },
   {
    title: '查询模式',
    align:"center",
    dataIndex: 'queryMode'
   },
   {
    title: '映射关系 0一对多  1一对一',
    align:"center",
    dataIndex: 'relationType'
   },
   {
    title: '子表',
    align:"center",
    dataIndex: 'subTableStr'
   },
   {
    title: '附表排序序号',
    align:"center",
    dataIndex: 'tabOrderNum'
   },
   {
    title: '树形表单父id',
    align:"center",
    dataIndex: 'treeParentIdField'
   },
   {
    title: '树表主键字段',
    align:"center",
    dataIndex: 'treeIdField'
   },
   {
    title: '树开表单列字段',
    align:"center",
    dataIndex: 'treeFieldname'
   },
   {
    title: '表单分类',
    align:"center",
    dataIndex: 'formCategory'
   },
   {
    title: 'PC表单模板',
    align:"center",
    dataIndex: 'formTemplate'
   },
   {
    title: '表单模板样式(移动端)',
    align:"center",
    dataIndex: 'formTemplateMobile'
   },
   {
    title: '是否有横向滚动条',
    align:"center",
    dataIndex: 'scroll'
   },
   {
    title: '复制版本号',
    align:"center",
    dataIndex: 'copyVersion'
   },
   {
    title: '复制表类型1为复制表 0为原始表',
    align:"center",
    dataIndex: 'copyType'
   },
   {
    title: '原始表ID',
    align:"center",
    dataIndex: 'physicId'
   },
   {
    title: '扩展JSON',
    align:"center",
    dataIndex: 'extConfigJson'
   },
   {
    title: '主题模板',
    align:"center",
    dataIndex: 'themeTemplate'
   },
   {
    title: '是否用设计器表单',
    align:"center",
    dataIndex: 'isDesForm'
   },
   {
    title: '设计器表单编码',
    align:"center",
    dataIndex: 'desFormCode'
   },
   {
    title: '关联的应用ID',
    align:"center",
    dataIndex: 'lowAppId'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '表名',
    field: 'tableName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入表名!'},
          ];
     },
  },
  {
    label: '表类型: 0单表、1主表、2附表',
    field: 'tableType',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入表类型: 0单表、1主表、2附表!'},
          ];
     },
  },
  {
    label: '表版本',
    field: 'tableVersion',
    component: 'InputNumber',
  },
  {
    label: '表说明',
    field: 'tableTxt',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入表说明!'},
          ];
     },
  },
  {
    label: '是否带checkbox',
    field: 'isCheckbox',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否带checkbox!'},
          ];
     },
  },
  {
    label: '同步数据库状态',
    field: 'isDbSynch',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入同步数据库状态!'},
          ];
     },
  },
  {
    label: '是否分页',
    field: 'isPage',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否分页!'},
          ];
     },
  },
  {
    label: '是否是树',
    field: 'isTree',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否是树!'},
          ];
     },
  },
  {
    label: '主键生成序列',
    field: 'idSequence',
    component: 'Input',
  },
  {
    label: '主键类型',
    field: 'idType',
    component: 'Input',
  },
  {
    label: '查询模式',
    field: 'queryMode',
    component: 'Input',
  },
  {
    label: '映射关系 0一对多  1一对一',
    field: 'relationType',
    component: 'InputNumber',
  },
  {
    label: '子表',
    field: 'subTableStr',
    component: 'Input',
  },
  {
    label: '附表排序序号',
    field: 'tabOrderNum',
    component: 'InputNumber',
  },
  {
    label: '树形表单父id',
    field: 'treeParentIdField',
    component: 'Input',
  },
  {
    label: '树表主键字段',
    field: 'treeIdField',
    component: 'Input',
  },
  {
    label: '树开表单列字段',
    field: 'treeFieldname',
    component: 'Input',
  },
  {
    label: '表单分类',
    field: 'formCategory',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入表单分类!'},
          ];
     },
  },
  {
    label: 'PC表单模板',
    field: 'formTemplate',
    component: 'Input',
  },
  {
    label: '表单模板样式(移动端)',
    field: 'formTemplateMobile',
    component: 'Input',
  },
  {
    label: '是否有横向滚动条',
    field: 'scroll',
    component: 'InputNumber',
  },
  {
    label: '复制版本号',
    field: 'copyVersion',
    component: 'InputNumber',
  },
  {
    label: '复制表类型1为复制表 0为原始表',
    field: 'copyType',
    component: 'InputNumber',
  },
  {
    label: '原始表ID',
    field: 'physicId',
    component: 'Input',
  },
  {
    label: '扩展JSON',
    field: 'extConfigJson',
    component: 'Input',
  },
  {
    label: '主题模板',
    field: 'themeTemplate',
    component: 'Input',
  },
  {
    label: '是否用设计器表单',
    field: 'isDesForm',
    component: 'Input',
  },
  {
    label: '设计器表单编码',
    field: 'desFormCode',
    component: 'Input',
  },
  {
    label: '关联的应用ID',
    field: 'lowAppId',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  tableName: {title: '表名',order: 0,view: 'text', type: 'string',},
  tableType: {title: '表类型: 0单表、1主表、2附表',order: 1,view: 'number', type: 'number',},
  tableVersion: {title: '表版本',order: 2,view: 'number', type: 'number',},
  tableTxt: {title: '表说明',order: 3,view: 'text', type: 'string',},
  isCheckbox: {title: '是否带checkbox',order: 4,view: 'text', type: 'string',},
  isDbSynch: {title: '同步数据库状态',order: 5,view: 'text', type: 'string',},
  isPage: {title: '是否分页',order: 6,view: 'text', type: 'string',},
  isTree: {title: '是否是树',order: 7,view: 'text', type: 'string',},
  idSequence: {title: '主键生成序列',order: 8,view: 'text', type: 'string',},
  idType: {title: '主键类型',order: 9,view: 'text', type: 'string',},
  queryMode: {title: '查询模式',order: 10,view: 'text', type: 'string',},
  relationType: {title: '映射关系 0一对多  1一对一',order: 11,view: 'number', type: 'number',},
  subTableStr: {title: '子表',order: 12,view: 'text', type: 'string',},
  tabOrderNum: {title: '附表排序序号',order: 13,view: 'number', type: 'number',},
  treeParentIdField: {title: '树形表单父id',order: 14,view: 'text', type: 'string',},
  treeIdField: {title: '树表主键字段',order: 15,view: 'text', type: 'string',},
  treeFieldname: {title: '树开表单列字段',order: 16,view: 'text', type: 'string',},
  formCategory: {title: '表单分类',order: 17,view: 'text', type: 'string',},
  formTemplate: {title: 'PC表单模板',order: 18,view: 'text', type: 'string',},
  formTemplateMobile: {title: '表单模板样式(移动端)',order: 19,view: 'text', type: 'string',},
  scroll: {title: '是否有横向滚动条',order: 20,view: 'number', type: 'number',},
  copyVersion: {title: '复制版本号',order: 21,view: 'number', type: 'number',},
  copyType: {title: '复制表类型1为复制表 0为原始表',order: 22,view: 'number', type: 'number',},
  physicId: {title: '原始表ID',order: 23,view: 'text', type: 'string',},
  extConfigJson: {title: '扩展JSON',order: 24,view: 'text', type: 'string',},
  themeTemplate: {title: '主题模板',order: 25,view: 'text', type: 'string',},
  isDesForm: {title: '是否用设计器表单',order: 26,view: 'text', type: 'string',},
  desFormCode: {title: '设计器表单编码',order: 27,view: 'text', type: 'string',},
  lowAppId: {title: '关联的应用ID',order: 28,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}